package com.compass.doctor.ui.home.view

import android.content.Context
import android.view.LayoutInflater
import android.widget.LinearLayout
import androidx.recyclerview.widget.LinearLayoutManager
import com.compass.doctor.databinding.ViewLatestCommentsBinding
import com.compass.doctor.ui.home.LatestCommentsActivity
import com.compass.doctor.ui.home.adapter.LatestCommentsAdapter
import com.compass.framework.ext.onClick
import com.compass.framework.model.Comment

/**
 * Description： 最新的评论
 * Date:2023/12/23 21:51
 */
class LatestCommentsView(context: Context?) : LinearLayout(context) {

    private var latestCommentsAdapter: LatestCommentsAdapter
    private var viewLatestCommentsBinding: ViewLatestCommentsBinding? = null

    init {
        viewLatestCommentsBinding =
            ViewLatestCommentsBinding.inflate(LayoutInflater.from(context), this, true)
        latestCommentsAdapter = LatestCommentsAdapter(1)
        viewLatestCommentsBinding?.apply {
            rcyRecommend.apply {
                layoutManager = LinearLayoutManager(context)
                adapter = latestCommentsAdapter

            }
            ivMoreAction.onClick {
                //更多评论
                context?.let { LatestCommentsActivity.start(it) }
            }
        }

    }

    /**
     * 设置内容，自行扩展
     */
    fun initData( commentList:MutableList<Comment>) {
        latestCommentsAdapter.setData(commentList)
    }
}